<template>
  <div class="main">
    <el-empty
      description="物品你还没有添加收藏哦"
      class="aaa"
      v-show="isShow"
    ></el-empty>
    <ul v-show="isShow==false">
      <router-link :to="{ path: '/proDetails', query: { i: i } }">
        <li
          v-for="(item, index) in product"
          :key="index"
          @click="click(item.id)"
          v-show="item.isCollect == true"
        >
          <img :src="item.bannerurl[0]" alt="" />
          <div class="content">
            <div class="name">{{ item.name }}</div>
            <div class="news">{{ item.introduce }}</div>
          </div>
        </li>
      </router-link>
    </ul>
  </div>
</template>

<script>
import { mapState } from "vuex";
export default {
  name: "compProFabulous",
  data() {
    return {
      isShow: true,
      i: 0,
    };
  },
  methods: {
    click(i) {
      this.i = i - 1;
    },
  },
  computed: {
    ...mapState(["product"]),
  },
  mounted() {
    for (let i = 0; i < this.product.length; i++) {
      if (this.product[i].isCollect) {
        this.isShow = false;
        return;
      } else {
        this.isShow = true;
      }
    }
  },
};
</script>

<style scoped lang="scss">
ul {
  padding: 10px 5px;
  box-sizing: border-box;
  border-radius: 20px;
  width: 100%;
  background: #fff;
  a {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    li {
      flex-basis: 50%;
      height: 250px;
      position: relative;
      border: 3px solid #fff;
      box-sizing: border-box;
      border-radius: 20px;
      box-shadow: 2px 2px 4px #ccc;
      img {
        border-radius: 20px;
        width: 100%;
        height: 100%;
      }
      .content {
        width: 100%;
        height: 100px;
        background: rgba(0, 0, 0, 0.5);
        position: absolute;
        bottom: 0;
        left: 0;
        color: #fff;
        padding: 0 10px;
        box-sizing: border-box;
        border-bottom-left-radius: 20px;
        border-bottom-right-radius: 20px;
        .name {
          width: 100%;
          height: 30px;
          line-height: 30px;
          font-size: 18px;
        }
        .news {
          width: 100%;
          height: 70px;
          line-height: 23px;
          color: rgb(180, 180, 180);
          font-size: 14px;
          display: -webkit-box;
          overflow: hidden;
          text-overflow: ellipsis;
          -webkit-box-orient: vertical;
          -webkit-line-clamp: 3;
        }
      }
    }
  }
}
</style>